const APIClient = require('./request.class');

const Model = {
    async getIndex() {
        const Api = new APIClient({
            url: 'https://www.xhj.com/',
            method: 'GET'
        })
        try {
            return res = await Api.html();
        } catch (err) {
            this.handleError(err);
        }
    },

    async getList() {
        const Api = new APIClient({
            url: 'https://www.xhj.com/ershoufang/',
            method: 'GET'
        })
        try {
            return res = await Api.html();
        } catch (err) {
            this.handleError(err);
        }
    },

    async getList1() {
        const Api = new APIClient({
            url: 'https://www.xhj.com/ershoufang/s1z1',
            method: 'GET'
        })
        try {
            return res = await Api.html();
        } catch (err) {
            this.handleError(err);
        }
    },

    async getDetail() {
        const Api = new APIClient({
            url: 'https://www.xhj.com/ershoufang/116219539.html',
            method: 'GET'
        })
        try {
            return res = await Api.html();
        } catch (err) {
            this.handleError(err);
        }
    },
    
    async getDetail1() {
        const Api = new APIClient({
            // url: 'https://www.xhj.com/ershoufang/115807254.html',
            url: 'https://www.xhj.com/daogou/40564.html',
            method: 'GET'
        })
        try {
            return res = await Api.html();
        } catch (err) {
            this.handleError(err);
        }
    },

    /**
     * 请求错误后提示
     * @param {Object} error
     */
     handleError(error) {
        console.log(error);
    },
};

module.exports = Model;